package com.qq.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author Bob
 */
@Aspect
@Component
public class MyAspect {

    // 定义一个命名切点
    @Pointcut("execution(* com.qq.bean..*(..))")
    public void pointCut() {}

    @Before("pointCut()")
    public void advice(){
        System.out.println("我是一个前置通知");
    }

    @After("pointCut()")
    public void advice2(){
        System.out.println("我就是一个后置通知");
    }

    @Around("pointCut()")
    public Object advice3(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("环绕通知开始");
        Object result = joinPoint.proceed();
        System.out.println("环绕通知结束");
        return result;
    }
}
